package com.shqcjd.preinstallmobile.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.preinstallmobile.R;
import com.shqcjd.preinstallmobile.model.pojo.TrackInfoBean;
import com.shqcjd.preinstallmobile.util.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 巡检设备
 * Created by sy on 2019/4/30.
 */

public class TrackInfoAdapter extends BaseQuickAdapter<TrackInfoBean.EquipmentsBean,TrackInfoAdapter.ViewHolder> {

    public TrackInfoAdapter() {
        super(R.layout.item_inspection_equimpent);
    }

    @Override
    protected void convert(ViewHolder helper, TrackInfoBean.EquipmentsBean item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small)	//加载错误之后的错误图
                .override(UIUtils.dip2px(80),UIUtils.dip2px(80))	//指定图片的尺寸
                .centerInside();
//                .centerCrop();//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(item.img)
                .apply(options)
                .into(helper.iv_img);

        helper.tv_pos.setText((helper.getLayoutPosition()+1)+"");
        helper.tv_name.setText(item.equipment_name);
        helper.tv_mfr.setText(item.equipment_type_name);
        helper.tv_kks.setText(item.kks);

    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_pos)
        TextView tv_pos;
        @BindView(R.id.iv_img)
        ImageView iv_img;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_mfr)
        TextView tv_mfr;
        @BindView(R.id.tv_kks)
        TextView tv_kks;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
